// Lang_28 [virtual functions].nova // The application class. class VirtualFunctionsApp { // Application class's "main" function. public static void main( String[] args ) { A a = new A( ), c = new C( ); Stream.writeLine( a.toString( ) ); Stream.writeLine( c.toString( ) ); Stream.writeLine( c.baseMethod( ) ); } } class A { public virtual String toString( ) { return "A.toString( )"; } public virtual A test1( ) { return this; } public String baseMethod( ) { // Call a local virtual method. return toString( ); } } class B : A { public String toString( ) { return "B.toString( )"; } // Overloaded virtual method with covariant return type. public B test1( ) { return this; } public virtual void test2( ) { } } class C : B { public String toString( ) { return "C.toString( )"; } // Overloaded virtual method with covariant return type. public C test1( ) { return this; } }